package com.jinunn.common.utils;

import com.jinunn.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 *  获取当前用户的信息类
 * @author : JinDun
 * @date : 2021/5/19 21:56
 */
public class AuthContextHolder {

    /**
     * 获取用户id
     */
    public static Long getUserId(HttpServletRequest request){
        String token = request.getHeader("token");
        return JwtHelper.getUserId(token);
    }

    /**
     * 获取当前用户名称
     */
    public static  String getUserName(HttpServletRequest request){
        String token = request.getHeader("token");
        return JwtHelper.getUserName(token);
    }
}
